package com.cowin.inf.controller;

import com.cowin.base.annotation.LogAnnotation;
import com.cowin.base.result.Result;
import com.cowin.base.result.ResultGenerator;
import com.cowin.base.BaseController;
import com.cowin.inf.model.KyBdcState;
import com.cowin.inf.model.KyUptimeRate;
import com.cowin.inf.model.vo.KyBdcStateVo;
import com.cowin.inf.model.vo.KyUptimeRateVo;
import com.cowin.inf.service.KyBdcStateService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by  on 2019/09/24.
 *
 * @author CodeGenerator
 */
@Slf4j
@RestController
@Api(value = "KyBdcStateController", description = "BDC状态控制器", tags = "KyBdcStateController", consumes = "application/json")
@RequestMapping("inf/ky/bdc/state")
public class KyBdcStateController extends BaseController<KyBdcState> {
    @Resource
    private KyBdcStateService kyBdcStateService;

    @ApiOperation(value = "BDC监控日志", notes = "BDC监控日志")
    @LogAnnotation("BDC监控日志")
    @PostMapping("/search")
    public Result searchBdcState(@RequestBody KyBdcStateVo kyBdcStateVo) {
        PageHelper.startPage(kyBdcStateVo.getPage(), kyBdcStateVo.getLimit());
        List<KyBdcState> list = kyBdcStateService.searchBdcState(kyBdcStateVo);
        PageInfo<KyBdcState> pageInfo = new PageInfo<>(list);
        return ResultGenerator.genSuccessResult(pageInfo);
    }

    @ApiOperation(value = "BDC监控修改", notes = "BDC监控修改")
    @PostMapping("/monitor")
    public Result updateBdcState(@RequestBody KyBdcState kyBdcState) {
        kyBdcStateService.updateBdcState(kyBdcState);
        return ResultGenerator.genSuccessResult();
    }
}
